{template header}

<script type="text/javascript" src="{SITE_URL}public/js/jquery.upload.v2.js"></script>

<div class="container">
<div class="row">
<div class="col-md-8">
    <div class="panel panel-default">
        <div class="panel-body">
			<ul class="nav nav-tabs" role="tablist">
				<li role="presentation" {if !$star&&!$status} class="active"{/if}>
					<a href="{tsUrl('duty','',null)}">记录</a>
				</li>
				<li role="presentation" {if $status} class="active"{/if}>
				<a href="{tsUrl('duty','index',array('groupid'=>$groupid,'orgid'=>$item['orgid'],'status'=>3,'begintime'=>$begintime,'endtime'=>$endtime,'star'=>$star,'page'=>$page))}" {if $noVerify>0}style='color:red'{/if}>待定</a>
				</li>
				<li role="presentation" {if $star} class="active"{/if}>
				<a href="{tsUrl('duty','index',array('star'=>1,'page'=>$page))}">精华</a>
				</li>
				<li role="presentation" ><a  href="{tsUrl('duty','sum',array('begintime'=>date('Y-m-d',strtotime('-1 month'))))}">统计</a></li>

				<li style="float: right">
					<a  class="btn btn-block" onclick="openform()"><i class="fa fa-filter"></i></a>
				</li>
				{if !isMobile()&& $GLOBALS['TS_USER']['isadmin']!= 0 }
				<li style="float: right" ><a   data-toggle="modal" data-target="#do_date_form1">导出</a></li>

				{/if}

			</ul>
			<br/>
<div class="clear" style="text-align:right;">{if $GLOBALS['TS_USER']!=''}<a class="btn btn-success btn-block"  onclick="showdutyform()">服务登记</a>{/if}</div>
			<form id="selectform" class="searchform" method="get" action="{tsUrl('duty','index',array('page'=>$page))}"  enctype="multipart/form-data" style="display: none;">
				<ul style="padding:10px;display: flex">
					<input type="hidden" name="app" value="duty">
					<input type="hidden" name="ac" value="index">
					<input type="hidden" name="page" value="{$page}">
					<input type="hidden" name="groupid" value="{$groupid}">
					<input type="hidden" name="orgid" value="{$orgid}">
					<input type="hidden" name="status" value="{$status}">
					<input type="hidden" name="star" value="{$star}">

					<li style="padding-right: 2px">
						<select onChange="MM_jumpMenu('parent',this,0)" style="font-size:10px;font-weight: 300;"  class="form-control">
							<option value="{tsUrl('duty','index',array('orgid'=>$orgid,'begintime'=>$begintime,'endtime'=>$endtime,'page'=>$page))}">全体</option>
							{loop $arrGroup $key $item}
							<option value="{tsUrl('duty','index',array('groupid'=>$item['groupid'],'orgid'=>$orgid,'status'=>$status,'begintime'=>$begintime,'endtime'=>$endtime,'star'=>$star,'page'=>$page))}" {if $groupid==$item['groupid']}selected{/if}>{$item['groupname']}</option>
							{/loop}
						</select>
					</li>
					<li style="padding-right: 2px">
						<select onChange="MM_jumpMenu('parent',this,0)" style="font-size:10px;font-weight: 300;" class="form-control">
							<option value="{tsUrl('duty','index',array('groupid'=>$groupid,'begintime'=>$begintime,'endtime'=>$endtime,'page'=>$page))}">所有机构</option>
							{loop $arrOrg $key $item}
							<option value="{tsUrl('duty','index',array('groupid'=>$groupid,'orgid'=>$item['orgid'],'status'=>$status,'begintime'=>$begintime,'endtime'=>$endtime,'star'=>$star,'page'=>$page))}" {if $orgid==$item['orgid']}selected{/if}>{$item['orgname']}</option>
							{/loop}
						</select>
					</li>
					<li style="padding-right: 2px">
						<input class="form-control" name="begintime" readonly value="{if $begintime} {$begintime}{/if}"  id="beginTime" placeholder="开始时间"/>
					</li>
					<li style="padding-right: 2px">
						<input class="form-control" name="endtime" readonly value="{if $endtime} {$endtime}{/if}" id="endTime"  placeholder="结束时间"/>
					</li>
					<li style="padding-right: 2px">
						<input class="btn btn-group-sm" type="submit" value="查询">
					</li>

				</ul>
			</form>

<div id="duty_list" class="duty_list" style="padding-top:10px" >
<ul>
	{loop $arrDuty $key $item}

	<li>

		<div class="userimg"><a href="{tsUrl('user','duty',array('id'=>$item[user][userid],'groupid'=>$strArticle[groupid]))}"><img class="img-rounded" src="{$item[user][face]}" width="32" height="32" alt="{$item['user']['username']}" title="{$item['user']['username']}" /></a></div>

		<div class="duty_title">
			<div class="title">

				<div class="author"><a href="{tsUrl('user','duty',array('id'=>$item[user][userid],'groupid'=>$strArticle[groupid]))}">{$item[user][username]}</a> <span style="float: right;color: #c0c0c0">{if $GLOBALS[TS_USER]['isadmin']==1}<a href="javascript:void('0');" onclick="{if $item[star]}no{/if}star('{$item[dutyid]}')">{/if}<i class="fa fa-star{if !$item[star]}-o{/if}"></i>{if $GLOBALS[TS_USER]['isadmin']==1}</a>{/if}&nbsp;&nbsp;&nbsp;&nbsp; {$item[count_recommend]}&nbsp;&nbsp;<i class="fa fa-heart"></i></span></div>
				<div class="content"  style="color:{if $item['status']==0}#c0c0c0{else}#000000{/if}"   onclick="redirect({$item['dutyid']})">
					{if $item['endtime']==0}{php echo date('Y-m-d',$item['begintime'])}{else}{php echo date('Y-m-d H:i',$item['begintime'])}至{php echo date('H:i',$item['endtime'])}{/if}在<a href="{tsUrl('duty','index',array('groupid'=>$item['groupid']))}">{php echo $item['address']}</a>执行{$item['cate']}，{if $item['commute']==0}服务{php echo $item['period']}小时{else}实际服务{$item['period']}小时，通勤时间{php echo $item['commute']}小时，合计耗时{php echo $item['term']}小时{/if}。{if $item['job']}<br/>{php echo delempty($item['job'])}{/if}
				</div>
				{if $item['image']}

				<div class="piclist">
					<ul>
						{loop $item['image'] $k $pic}
						<li style="border-bottom: none"><a href="{$pic}"><img style="width:100px;height: auto;position:absolute; clip:rect(0px 120px 70px 0px); " src="{$pic}"></a></li>

						{/loop}
					</ul>
				</div>
				{/if}
				{if $item['comment']}

					<ul style="background-color: #f7f7f7;border-radius: 5%;margin-top: 20px">
						{loop $item['comment'] $k $v}
							<li style="border-bottom: 0px;">
								<div class="userimg"><a href="{tsUrl('user','duty',array('id'=>$v[user][userid]))}"><img class="img-rounded" src="{$v[user][face]}" width="32" height="32" alt="{$v['user']['username']}" title="{$v['user']['username']}" /></a></div>
								<div class="duty_title">
									<div class="title">
										<div class="author"><a href="{tsUrl('user','duty',array('id'=>$v[user][userid]))}">{$v[user][username]}</a>&nbsp;&nbsp;{php echo getTime($v[addtime],time())}</div>
										<div class="content">{$v[content]}</div>
										{if $GLOBALS[TS_USER][userid] == $item[userid] || $GLOBALS[TS_USER]['isadmin']==1}
										<span><a style="float:right" href="{SITE_URL}index.php?app=duty&ac=delcomment&commentid={$v['commentid']}"  rel="nofollow">删除</a> </span>
										{/if}
									</div>
								</div>

							</li>

						{/loop}
					</ul>

				{/if}
<div style="text-align:right;font-size: x-small;color: #777777">



	{if $GLOBALS[TS_USER][userid]==$item['userid']&&$item['status']==1}

	<a class="btn btn-w" style="background-color: #419641;color: #FFFFFF" href="{tsUrl('duty','card',array('dutyid'=>$item[dutyid]))}">打卡</a>

	{/if}

	{if $item['articleid']>0}
	<a class="btn btn-w" href="{tsUrl('article','show',array('id'=>$item[articleid]))}{$mylink}">读文档</a>
	{/if}


	{if $GLOBALS[TS_USER][userid]==$item['userid']}


{/if}
	{if $GLOBALS['TS_USER']['isadmin']=='1'||($item['status']==0&&$GLOBALS[TS_USER][userid]==$item['userid'])}<a  class="btn btn-w" href="{tsUrl('duty','show',array('dutyid'=>$item[dutyid],'edit'=>1))}" >修改</a>{/if}
	{if $item['status']==0&&($GLOBALS['TS_USER']['isadmin']=='1'||$GLOBALS[TS_USER][userid]==$item['userid'])}<a  class="btn btn-w" href="javascript:void(0)" onclick="delDuty('{$item['dutyid']}')">删除</a>{/if}
	{if (in_array($GLOBALS['TS_USER']['userid'],$item['group']['admin'])||$GLOBALS['TS_USER']['isadmin']=='1')&&$item['status']==0}<a  class="btn btn-w" href="javascript:void(0)" onclick="verify({$item['dutyid']})">核定</a>{/if}
	{if (in_array($GLOBALS['TS_USER']['userid'],$item['group']['admin'])||$GLOBALS['TS_USER']['isadmin']=='1')&&$item['status']==1}<a class="btn btn-w" href="javascript:void(0)" onclick="cancel({$item['dutyid']})">取消核定</a>{/if}
	{if $GLOBALS[TS_USER][userid]&&$item['status']==1&&$item[userid]!=$GLOBALS[TS_USER][userid]}
	<a class="btn btn-w" href="javascript:void(0)" onclick="recommend('{$item[dutyid]}')">{if $item[isrecommend]==0} 点赞{else} 取消点赞{/if}</a>
	{/if}
  {if $GLOBALS[TS_USER][userid]>0}
	<a class="btn btn-w" href="javascript:void(0)" onclick="add_comment('{$item[dutyid]}')">评论</a>
	{/if}

</div>
</div>
</div>
</li>

{/loop}
</ul>


<div class="clear"></div>
<div class="page">{$pageUrl}</div>



</div>

			<div id="do_duty_form" style="display: none">
							<br/>
							<form  id="record" class="form-horizontal" method="post" action="{SITE_URL}index.php?app=user&ac=do&ts=add">

								{if $myDuty!='' }
								<input type="hidden" id="dutyid" name="dutyid" value="{php echo($myDuty['dutyid'])}">
								{/if}
								<input type="hidden" id="userid" name="userid" value="{$GLOBALS[TS_USER][userid]}">
								<input type="hidden" id="renzheng" name="renzheng" value="{$GLOBALS[TS_USER][isrenzheng]}">
								<div class="form-group">
									<label class="col-sm-3 control-label">身份证号（或护照号等）</label>
									<div class="col-sm-9">
										<input type="text" class="form-control" id="idcard" name="idcard" value="{$GLOBALS['TS_USER']['idcard']}" placeholder="请输入身份证号（或护照号等），否则服务时长无法按月导入官方志愿平台">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">姓名</label>
									<div class="col-sm-9">
										<input type="text" class="form-control" id="username" name="username" value="{$GLOBALS['TS_USER']['username']}">
									</div>
								</div>
								{if $myDuty =='' }
								<div class="form-group">
									<label class="col-sm-3 control-label">服务类型</label>
									<div class="col-sm-9">
										<select onChange="checkRenzheng(this.options[this.options.selectedIndex].value,{$_SESSION['tsuser']['isrenzheng']})" name="cateid" id="cateid" class="form-control">
											<option value=""></option>
											{loop $arrCate $key $item}

											<option value="{$item['cateid']}"  {if $lastOrder['cateid']==$item['cateid']}selected{/if} >{$item['catename']}</option>

											{/loop}
										</select>
									</div>
								</div>
								{else}
								<input type="hidden" id="cateid" name="cateid" value="1">
								{/if}
								<div class="form-group">
									<label class="col-sm-3 control-label">服务处所</label>
									<div class="col-sm-9">
										<select  name="groupid" id="gid" class="form-control">
											<option value=""></option>
											{loop $arrGroup $key $item}
											{if $mygroupid}
											<option value="{$item['groupid']}" {if $item['groupid']==$mygroupid}selected{/if}>{$item['groupname']}</option>
											{else}
											{if $groupid}
											<option value="{$item['groupid']}" {if $item['groupid']==$groupid}selected{/if}>{$item['groupname']}</option>
											{else}
											<option value="{$item['groupid']}" {if $item['groupid']==$_SESSION['tsuser']['groupid']}selected{/if}>{$item['groupname']}</option>
											{/if}
											{/if}
											{/loop}
										</select>
									</div>
								</div>


								<div class="form-group">
									<label class="col-sm-3 control-label">服务起始时间</label>
									<div class="col-sm-3">
										<input class="form-control" name="begindate" readonly value="{if $lastOrder}{php echo date('Y-m-d H:i',$lastOrder['begintime'])}{/if}" id="beginDate" />
									</div>

								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">服务结束时间</label>
									<div class="col-sm-3">
										<input class="form-control" name="enddate" readonly value="{if $lastOrder}{php echo date('Y-m-d H:i',$lastOrder['endtime'])}{/if}" id="endDate" />
									</div>
								</div>


								<div class="form-group">
									<label class="col-sm-3 control-label">实际耗时（小时）</label>
									<div class="col-sm-9">
										<input type="text" class="form-control" name="period" id="period" placeholder="可留空，根据起止时间自动计算">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">通勤时长（小时）</label>
									<div class="col-sm-9">
										<input type="text" class="form-control" name="commute" id="commute" value="{$lastDuty[commute]}">
									</div>
								</div>

								<div class="form-group">
									<label class="col-sm-3 control-label">
										工作小结及注意事项{if $draft==''}<a class="btn btn-xs" href="{php echo(curPageURL())}&draft=1">恢复丢失内容</a>{/if}
									</label>
									<div class="col-sm-9" >
										<div id="tseditor"></div>
										<div style="display: none">
											<textarea id="job" name="content" class="form-control" style="width: 100%"  rows="5" placeholder="简要记录一下做了什么，以及需要提醒伙伴注意的情况"></textarea>
										</div>
										<!--<div  name="job" id="tseditor" rows="5" placeholder="简要记录一下做了什么，以及需要提醒伙伴注意的情况">-->
									</div>
								</div>
								<div class="form-group">
									<div class="col-sm-offset-2 col-sm-10">
										<button data-id="submit" type="submit" class="btn btn-success">点击提交</button>
									</div>
								</div>
							</form>
			</div>

</div>
		</div>
	</div>


<div class="col-md-4">

    <!--广告位-->
    {php doAction('gobad','300')}
</div>


</div>
</div>

<div id="do_search_form" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h5 class="modal-title">筛选范围</h5>
			</div>
			<div class="modal-body" >
				<form id="search" class="form-horizontal" method="get" action="{SITE_URL}index.php">
					<input type="hidden" name="app" value="duty" />
					<div class="form-group">
						<label class="col-sm-2 control-label">服务处所</label>
						<div class="col-sm-9">
							<select  name="groupid" id="groupid" class="form-control">
								<option></option>
								{loop $arrGroup $key $item}
								<option value="{$item['groupid']}" {if $item['groupid']==$groupid}selected{/if}>{$item['groupname']}</option>
								{/loop}
							</select>
						</div>

					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">所属机构</label>
						<div class="col-sm-9">
							<select  name="orgid" id="orgid" class="form-control">
								<option></option>
								{loop $arrOrg $key $item}
								<option value="{$item['orgid']}" >{$item['orgname']}</option>
								{/loop}
							</select>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">日期</label>
						<div class="col-sm-3"><select  data-name="year" name="year" class="form-control"></select></div>
						<div class="col-sm-3"><select  data-name="month" name="month" class="form-control"></select></div>
						<div class="col-sm-3"><select  data-name="day"  name="day" class="form-control"></select></div>
					</div>

					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-success">开始筛选</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>




<div id="do_date_form" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h5 class="modal-title">选择范围</h5>
			</div>
			<div class="modal-body" >
					<form  id="date-form" class="form-horizontal" method="post" action="{SITE_URL}index.php?app=duty&ac=excel">
						<div class="form-group">
							<label class="col-sm-2 control-label">服务处所</label>
							<div class="col-sm-9">
								<select  name="groupid" id="groupid" class="form-control">
									<option></option>
									{loop $arrGroup $key $item}
									<option value="{$item['groupid']}" {if $item['groupid']==$groupid}selected{/if}>{$item['groupname']}</option>
									{/loop}
								</select>
							</div>

						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">所属机构</label>
							<div class="col-sm-9">
								<select  name="orgid" id="orgid" class="form-control">
									<option></option>
									{loop $arrOrg $key $item}
									<option value="{$item['orgid']}" >{$item['orgname']}</option>
									{/loop}
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">起始日期</label>
							<div class="col-sm-3"><select  data-name="year" name="beginyear" class="form-control"></select></div>
							<div class="col-sm-3"><select  data-name="month" name="beginmonth" class="form-control"></select></div>
							<div class="col-sm-3"><select  data-name="day"  name="beginday" class="form-control"></select></div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">截止日期</label>
							<div class="col-sm-3"><select  data-name="year" name="endyear" class="form-control"></select></div>
							<div class="col-sm-3"><select  data-name="month" name="endmonth" class="form-control"></select></div>
							<div class="col-sm-3"><select  data-name="day"  name="endday" class="form-control"></select></div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-2 col-sm-10">
								<button type="submit" class="btn btn-success">点击提交</button>
							</div>
						</div>
					</form>
			</div>
		</div>
	</div>
</div>

<div id="do_date_form1" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h5 class="modal-title">选择范围</h5>
			</div>
			<div class="modal-body" >
				<form  id="date-form" class="form-horizontal" method="post" action="{SITE_URL}index.php?app=duty&ac=exporttext">
					<!--
					<div class="form-group">
						<label class="col-sm-2 control-label">服务处所</label>
						<div class="col-sm-9">
							<select  name="groupid" id="groupid" class="form-control">
								<option></option>
								{loop $arrGroup1 $key $item}
								<option value="{$item['groupid']}" {if $item['groupid']==$groupid}selected{/if}>{$item['groupname']}</option>
								{/loop}
							</select>
						</div>

					</div>
					-->
					<div class="form-group">
						<label class="col-sm-2 control-label">起始日期</label>
						<div class="col-sm-3"><select   id="begin_year" name='beginyear' class="form-control"></select></div>
						<div class="col-sm-3"><select   id="begin_month" name='beginmonth' class="form-control"></select></div>
						<div class="col-sm-3"><select   id="begin_day" name="beginday" class="form-control"></select></div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">截止日期</label>
						<div class="col-sm-3"><select  id="end_year" name="endyear" class="form-control"></select></div>
						<div class="col-sm-3"><select  id="end_month" name="endmonth" class="form-control"></select></div>
						<div class="col-sm-3"><select  id="end_day" name="endday" class="form-control"></select></div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-success">点击提交</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<div id="do_open_form" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h5 class="modal-title">选择范围</h5>
			</div>
			<div class="modal-body" >
				<form  id="open-form" class="form-horizontal" method="post" action="{SITE_URL}index.php?app=duty&ac=openday">

					<div class="form-group">
						<label class="col-sm-2 control-label">起始日期</label>
						<div class="col-sm-3"><select  data-name="year" name="beginyear" class="form-control"></select></div>
						<div class="col-sm-3"><select  data-name="month" name="beginmonth" class="form-control"></select></div>
						<div class="col-sm-3"><select  data-name="day"  name="beginday" class="form-control"></select></div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">截止日期</label>
						<div class="col-sm-3"><select  data-name="year" name="endyear" class="form-control"></select></div>
						<div class="col-sm-3"><select  data-name="month" name="endmonth" class="form-control"></select></div>
						<div class="col-sm-3"><select  data-name="day"  name="endday" class="form-control"></select></div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-success">点击提交</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>


{if $register==1}
<script>
	$('#duty_list').hide();
	$('#do_duty_form').show();
</script>

{/if}

<script>
	function checkRenzheng(cateid,isrenzheng){

		if(cateid==1&&isrenzheng==0){
			tsNotice('你还没有取得馆员资格！如果已经通过了考试，请点击<a href="{tsUrl('user','apply')}">这里</a>申报馆员资格；如果还没有参加培训和考试，请点击<a href="https://shimo.im/docs/fatOK9bmivgLQwuL">这里</a>查看了解详情。参加培训，通过考试取得馆员资格后，这条提示会自动消失。');
		}
	}


	//隐藏列表，显示登记表单
	function showdutyform(){
		$('#duty_list').hide();
		$('#do_duty_form').show();
	}


	//筛选分馆
	function jumpto(url,groupid){

       window.location.href=url+'&groupid='+groupid;
	}



	//统计截止时间表单
	function doDateForm(){

			var content = $("#do_date_form").html();
			tsNotice(content);

	}



	//登记服务填写表单
	function doDutyForm(userid){

		if(userid==0){
			tsNotice('请登录后再操作！');
		}else{

			var content = $("#do_duty_form").html();
			tsNotice(content);
		}
	}
	//删除服务记录
	function delDuty(dutyid){


		if (confirm('删除这条服务记录吗？')) {

			$.ajax({
				type: "POST",
				url: siteUrl+"index.php?app=user&ac=do&ts=del",
				data: "dutyid="+dutyid,
				beforeSend:function(){
				},
				success:function(result){
					if(result == '1'){
						window.location.reload();
					}
				}
			});

		}
	}
	//核定服务记录
	function verify(dutyid){


		if (confirm('核定这条服务记录吗？')) {

			$.ajax({
				type: "POST",
				url: siteUrl+"index.php?app=user&ac=do&ts=verify",
				data: "dutyid="+dutyid,
				beforeSend:function(){
				},
				success:function(result){
						window.location.reload();
				}
			});

		}
	}

	//取消核定
	function cancel(dutyid){

		if (confirm('取消核定这条服务记录吗？')) {

			$.ajax({
				type: "POST",
				url: siteUrl+"index.php?app=user&ac=do&ts=cancel",
				data: "dutyid="+dutyid,
				beforeSend:function(){
				},
				success:function(result){
					if(result == '1'){
						window.location.reload();
					}
				}
			});
		}
	}

	//加星
	function star(dutyid){

			$.ajax({
				type: "POST",
				url: siteUrl+"index.php?app=user&ac=do&ts=star",
				data: "dutyid="+dutyid,
				beforeSend:function(){
				},
				success:function(result){
					if(result == '1'){
						window.location.reload();
					}
				}
			});

	}

	//去星
	function nostar(dutyid){

		$.ajax({
			type: "POST",
			url: siteUrl+"index.php?app=user&ac=do&ts=nostar",
			data: "dutyid="+dutyid,
			beforeSend:function(){
			},
			success:function(result){
				if(result == '1'){
					window.location.reload();
				}
			}
		});

	}

	$(function(){


		$('#record').on('submit', function(e) {
			var dutyid  = $('#dutyid').val();
			var idcard = $.trim($('#idcard').val());
			var username = $('#username').val();
			var groupid  = $('#gid').val();
			var cateid  = $('#cateid').val();
			var begindate  = $('#beginDate').val();
			var enddate  = $('#endDate').val();
			var period  = $('#period').val();
			var commute  = $('#commute').val();
			var job  = $('#job').val();
			var renzheng = $('#renzheng').val();



			if (cateid == '') {
				bootbox.alert('服务类型不能为空');
				return false;
			}

			if (groupid == '') {
				bootbox.alert('服务处所不能为空');
				return false;
			}


			if (cateid == '1' && groupid=='1') {
				bootbox.alert('服务类型与服务处所不匹配');
				return false;
			}

			if (begindate == '' ||  enddate=='') {
				bootbox.alert('起止时间不能为空');
				return false;
			}

			//if (job == '<p><br></p>') {
				//bootbox.alert('工作小结简单写几句呗');
				//return false;
			//}

            if(username == ''){
				bootbox.alert('朋友，做好事也要留名哦');
				return false;
			}


		});




	});

    var date = new Date();
	$('#beginTime').datetimepicker({
		language:  'zh-CN',
		format: 'yyyy-mm-dd',
		autoclose: true,
		minView:2,
		endDate: date
	});

	$('#endTime').datetimepicker({
		language:  'zh-CN',
		format: 'yyyy-mm-dd',
		autoclose: true,
		minView:2,
		endDate: date
	});

	$('#beginDate').datetimepicker({
		language:  'zh-CN',
		format: 'yyyy-mm-dd hh:ii',
		autoclose: true,
		minView:0,
        endDate: date
	});

	$('#endDate').datetimepicker({
		language:  'zh-CN',
		format: 'yyyy-mm-dd hh:ii',
		autoclose: true,
		minView:0,
        endDate: date
	});

	$(document).ready(function(e) {
		var date = new Date();
		var vYear = date.getFullYear();
		var vMon = date.getMonth() + 1;
		var vDay = date.getDate();
		var year;
		var month;
		var day;
		var str_year;
		var str_month;
		var t_month;
		var str_day;

	//	{if $myDuty!=''}
		//	vYear = {php echo date('Y',$myDuty['begintime'])};
			//vMon  = {php echo date('m',$myDuty['begintime'])};
		//	vDay  = {php echo date('d',$myDuty['begintime'])};
		//	{/if}

				var first_year = 2017;
//起始
				var last_year = date.getFullYear();
//终止年
				var t_year
				var i;
				var r;
				var y_v;
				var m_v;
				var d_v;
//写出年的选项
				$("[data-name=year]").append('<option value=""></option>');
				for (i = last_year; i >= first_year; i--) {

					if (i != vYear) {
						$("[data-name=year]").append('<option value="' + i + '">' + i + '</option>');
					} else {
						$("[data-name=year]").append('<option value="' + i + '" selected>' + i + '</option>');
					}
				}
//写出月的选项
				$("[data-name=month]").append('<option value=""></option>');
				for (i = 1; i <= 12; i++) {
					r = i ;
					if (i != vMon) {
						$("[data-name=month]").append('<option value="' + i + '">' + r + '</option>');
					} else {
						$("[data-name=month]").append('<option value="' + i + '" selected>' + r + '</option>');
					}
				}

//初始化日的值
				getday();
//在年月的值发生变化时计算日期的天数
				$("[data-name=year]").change(function(){   getday();   });
				$("[data-name=month]").change(function(){ getday();
				});
//根据日期的天数，输出日选项

				function getday(){
					var y_v=$("[data-name=year]").val();
					var m_v=$("[data-name=month]").val()-1;
					var d_v;
					var i;
					if((y_v%100!=0&&y_v%4==0)||y_v%400==0) {
						d_v=new Array(31,29,31,30,31,30,31,31,30,31,30,31);
					}    else   {
						d_v=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
					}
					$("[data-name=day]").html("");
					$("[data-name=day]").append('<option value=""></option>');
					for(i=1;i<=d_v[m_v];i++)   {
						//if(i!=vDay)  {
						$("[data-name=day]").append('<option value="'+i+'">'+i+'</option>');
						//	}  else {
						//	$("[data-name=day]").append('<option value="'+i+'" selected>'+i+'</option>');
						//	}
					}
				}
			});

	$(function() {
		$.ms_DatePicker({
			YearSelector: "#begin_year",
			MonthSelector: "#begin_month",
			DaySelector: "#begin_day",
			FirstText: "{php date('Y-m-d',time())}"
		});
		$.ms_DatePicker({
			YearSelector: "#end_year",
			MonthSelector: "#end_month",
			DaySelector: "#end_day"
		});
	});


</script>
{php doAction('tseditor','m')}
{template footer}